home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / Imaging / Rotate 90 CCW < prev    next >
Encoding:
Text File  |  1999-03-04  |  3.8 KB  |  163 lines  |  [TEXT/ToyS]

  1. -- Properties
  2. property kasName : "Rotate CCW V1.0"
  3. property kasRotate : -900 -- Back 90 degrees
  4. property kasPause : 5 -- Time to preview
  5.  
  6. -- Globals
  7. global gasInfoWind -- Info window
  8.  
  9. global gasFoldersToDo -- The folders left to process
  10. global gasShown -- Number gone!
  11. global gasDone -- Number checked!
  12.  
  13.  
  14. on open fsObjs
  15.     -- Set up prefix
  16.     set gasShown to 0
  17.     set gasDone to 0
  18.     
  19.     set gasInfoWind to display info titled kasName message "Starting…" located at {20, 40}
  20.     
  21.     -- Do files
  22.     set gasFoldersToDo to {}
  23.     
  24.     repeat with fsObj in fsObjs
  25.         set myInfo to (basic info for fsObj)
  26.         
  27.         if (the catalog kind of myInfo is a folder) then
  28.             set gasFoldersToDo to gasFoldersToDo & {fsObj}
  29.         else
  30.             DoOne(fsObj)
  31.         end if
  32.     end repeat
  33.     
  34.     -- Do folders
  35.     repeat while gasFoldersToDo is not {}
  36.         -- Pop one off the end
  37.         set n to the number of items of gasFoldersToDo
  38.         set fsObj to item n of gasFoldersToDo
  39.         set gasFoldersToDo to edit list gasFoldersToDo with edits {n} with removal of items
  40.         
  41.         display info gasInfoWind ¬
  42.             message ("Folders to go: " & n) ¬
  43.             at line 6 ¬
  44.             using color (15 * 32)
  45.         
  46.         -- Process it
  47.         GoDeep(fsObj)
  48.     end repeat
  49.     
  50.     ShowAction("Done!")
  51.     
  52.     pause for 5 with seconds timing -- Let screen wait...
  53.     
  54.     set gasInfoPos to screen location of ¬
  55.         (display info gasInfoWind with disposal)
  56. end open
  57.  
  58.  
  59. on DoOne(fsObj)
  60.     set imageType to the image type in fsObj
  61.     set fname to (catalog name of (basic info for fsObj))
  62.     set newFile to (fsObj as string) & ".b" & (kasRotate div 10)
  63.     
  64.     ShowFile(fname)
  65.     
  66.     if (imageType is not "") then
  67.         ShowImageType(imageType)
  68.         
  69.         -- Get picture
  70.         try
  71.             set pic to the image from fsObj
  72.         on error errStr number errNum
  73.             ShowError(errStr, errNum)
  74.         end try
  75.         
  76.         -- Rotate it
  77.         set pinf to the picture info for pic
  78.         set pic to rotate image pic by kasRotate
  79.         
  80.         -- Show it
  81.         set showPic to display drawing titled fname starting with pic
  82.         
  83.         -- Save it
  84.         if (picture compressed quality of pinf) is 0 then
  85.             store image pic in newFile as imageType
  86.         else
  87.             store image pic in newFile as imageType ¬
  88.                 with percent quality (picture compressed quality of pinf)
  89.         end if
  90.         
  91.         set the icon of newFile to pic
  92.         -- And out        
  93.         pause for kasPause with seconds timing
  94.         display drawing showPic with disposal
  95.     else
  96.         ShowFault("No image!")
  97.     end if
  98. end DoOne
  99.  
  100.  
  101. on GoDeep(foldObj)
  102.     ShowPath(foldObj)
  103.     
  104.     set daddy to foldObj as string
  105.     
  106.     -- Do kinds that match    
  107.     set myItems to the entries in foldObj whose kinds are a file
  108.     set n to the number of items in myItems
  109.     ShowAction("Scanning files (" & n & ")")
  110.     
  111.     repeat with myItem in myItems
  112.         DoOne((daddy & myItem) as alias)
  113.     end repeat
  114.     
  115.     -- Do folders
  116.     ShowAction("Scanning subfolders…")
  117.     set myItems to the entries in foldObj whose kinds are a folder
  118.     
  119.     repeat with myItem in myItems
  120.         set gasFoldersToDo to gasFoldersToDo & {(daddy & myItem) as alias}
  121.     end repeat
  122.     
  123.     -- Done
  124.     ShowAction("…")
  125. end GoDeep
  126.  
  127.  
  128. on ShowPath(pth)
  129.     display info gasInfoWind message "Current Folder: " & (pth as string)
  130. end ShowPath
  131.  
  132.  
  133. on ShowFile(fname)
  134.     display info gasInfoWind message fname at line 2
  135. end ShowFile
  136.  
  137.  
  138. on ShowImageType(iType)
  139.     display info gasInfoWind message ("Found image type: " & iType) at line 3 using color 15
  140. end ShowImageType
  141.  
  142.  
  143. on ShowFault(msg)
  144.     display info gasInfoWind message msg at line 4 using color 12 * 1024
  145.     pause for 120
  146.     display info gasInfoWind message "…" at line 4
  147. end ShowFault
  148.  
  149.  
  150. on ShowAction(msg)
  151.     display info gasInfoWind message msg at line 5
  152. end ShowAction
  153.  
  154.  
  155. on ShowError(errStr, errNum)
  156.     display info gasInfoWind message "An error occured:" at line 6 using color (30 * 1024) using bg color 0
  157.     display info gasInfoWind message (errStr) at line 7 using color (30 * 1024) using bg color 0
  158.     display info gasInfoWind message "(Error number: " & errNum & ")" at line 8 using color (30 * 1024) using bg color 0
  159.     beep
  160.     pause for 180
  161.     display info gasInfoWind message "The last error was:" at line 6
  162. end ShowError
  163.